<!--
  @author yangjiangming
  @date 2018-12-10 20:40:28
-->
<!DOCTYPE HTML>
<html th:replace="~{work/modify/common/layout :: layout('保修信息', ~{::title}, ~{::content}, ~{::script})}"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <title>工单管理-保修信息</title>
</head>
<body>

<div th:fragment="content">
        <div id="view"></div>
</div>

<script id="card" type="text/html">
    <form class="layui-form" th:each="warrantyProductVO,iterStat:${orderWarrantyVO.warrantyProductVOList}"  th:hidden="${warrantyProductVO.selected} eq 1" th:cols="${iterStat.index}" action="">
        <input type="hidden" name="proExtId" th:value="${warrantyProductVO.proExtId}">
        <input type="hidden" name="productId" th:value="${warrantyProductVO.productId}">
        <input type="hidden" name="orderId" th:value="${orderWarrantyVO.orderId}">
        <input type="hidden" name="workId" th:value="${orderWarrantyVO.workId}">
        <input type="hidden" name="operatorId" th:value="${operatorId}">
        <div class="layui-form-item">
            <label class="layui-form-label">产品名称</label>
            <div class="layui-input-inline" style="width: 240px">
                <span style="line-height: 34px; " class="productName" th:text="${warrantyProductVO.productName}"></span>
            </div>

            <!-- 兼容历史工单，历史工单不允许操作 -->
            <th:block th:if="${orderWarrantyVO.code == null}">
            <div class="layui-inline" style="float: right">
                <div class="layui-btn-group layui-inline" >
                    <button class="layui-btn layui-btn-sm modify-btn" lay-submit lay-filter="modify"  >
                        <i class="layui-icon">&#xe642;</i>修改
                    </button>
                    <button class="layui-btn layui-btn-sm delete-btn"  lay-submit lay-filter="delete">
                        <i class="layui-icon">&#xe640;</i>删除
                    </button>
                    <button class="layui-btn layui-btn-sm save-btn " lay-submit lay-filter="save" style="display: none">
                        <i class="layui-icon">&#xe605;</i>保存
                    </button>
                    <button class="layui-btn layui-btn-sm cancel-btn " lay-submit lay-filter="cancel" style="display: none">
                        <i class="layui-icon">&#x1006;</i>取消
                    </button>
                </div>
            </div>
            </th:block>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">保修规则</label>
            <div class="layui-input-inline" style="width: 240px">
                <th:block th:if="${warrantyProductVO.warrantyFault != null and warrantyProductVO.warrantyFault.ruleName != null and orderWarrantyVO.code == null }">
                    <span style="line-height: 34px;"   th:text="${warrantyProductVO.warrantyFault.ruleName}"></span>
                    <input type="hidden" name="ruleId" th:value="${warrantyProductVO.warrantyFault.ruleId}">
                </th:block>

                <!-- 兼容历史工单数据 无不显示 -->
                <th:block th:if="${orderWarrantyVO.code != null }">
                    <span style="line-height: 34px; " class="productName" th:text="---"></span>
                </th:block>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">保修范围</label>
                <div class="layui-input-block fault-list">
                    <th:block th:if="${warrantyProductVO.warrantyFault != null and not #lists.isEmpty(warrantyProductVO.warrantyFault) and orderWarrantyVO.code == null}">
                        <input type="checkbox" th:if="${warrantyProductVO.selected} eq 2" th:each="fault:${warrantyProductVO.warrantyFault.allFault}" name="fault" th:title="${fault.mapName}"  th:value="${fault.mapId}"  th:checked="${#lists.contains(warrantyProductVO.fault,fault)}" />
                        <input type="checkbox" th:if="${warrantyProductVO.selected} eq 1" th:each="fault:${warrantyProductVO.warrantyFault.allFault}" name="fault" th:title="${fault.mapName}"  th:value="${fault.mapId}" />
                    </th:block>

                    <!-- 兼容历史工单数据 只用于回显 -->
                    <th:block th:if="${orderWarrantyVO.code != null }">
                        <input type="checkbox" name="fault" th:each="fault:${warrantyProductVO.fault}" th:title="${fault.mapName}" checked="checked" th:value="${fault.mapId}"/>
                    </th:block>
                </div>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <textarea placeholder="其他保修" name="remark" class="layui-textarea" th:text="${warrantyProductVO.remark}"></textarea>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">保修时长</label>
            <div class="layui-input-block modify-day">
                <th:block th:if="${orderWarrantyVO.code == null }">
                    <th:block th:if="${warrantyProductVO.warrantyFault != null and not #lists.isEmpty(warrantyProductVO.warrantyFault)}">
                        <input type="radio" th:each="day:${warrantyProductVO.warrantyFault.days}" name="day"
                               th:title="${day}+'天'" th:value="${day}" th:checked="${day} == ${warrantyProductVO.day}"/>

                        <th:block th:if="${warrantyProductVO.day != null and warrantyProductVO.day != ''}">
                            <th:block th:checked="${not #lists.isEmpty(warrantyProductVO.warrantyFault) }">
                                <th:block th:if="${not warrantyProductVO.warrantyFault.days.contains(warrantyProductVO.day)}">
                                    <input type="radio" name="day" th:title="${warrantyProductVO.day}+'天'" th:value="${warrantyProductVO.day}" checked="checked"/>
                                </th:block>
                            </th:block>
                        </th:block>
                    </th:block>
                </th:block>

                <!-- 兼容历史工单数据，只用于回显 -->
                <th:block th:if="${orderWarrantyVO.code != null }">
                    <input type="radio" title="不保修" value="0" th:checked="${warrantyProductVO.month} eq 0" lay-filter="month" name="month"/>
                    <input type="radio" title="一个月" value="1" th:checked="${warrantyProductVO.month} eq 1" lay-filter="month" name="month"/>
                    <input type="radio" title="二个月" value="2" th:checked="${warrantyProductVO.month} eq 2" lay-filter="month" name="month"/>
                    <input type="radio" title="三个月" value="3" th:checked="${warrantyProductVO.month} eq 3" lay-filter="month" name="month"/>
                    <input type="radio" title="四个月" value="4" th:checked="${warrantyProductVO.month} eq 4" lay-filter="month" name="month"/>
                    <input type="radio" title="五个月" value="5" th:checked="${warrantyProductVO.month} eq 5" lay-filter="month" name="month"/>
                    <input type="radio" title="六个月" value="6" th:checked="${warrantyProductVO.month} eq 6" lay-filter="month" name="month"/>
                    <input type="radio" title="一年" value="12" th:checked="${warrantyProductVO.month} eq 12" lay-filter="month" name="month"/>
                </th:block>
            </div>

            <div class="layui-input-block modify-add-day" style="display: none">
                <div class="layui-inline d-width-input ">
                    <input type="text" name="addDay" lay-verify="day-number" placeholder="请输入保修天数" class="layui-input" autocomplete="off" >
                </div>
                <div class="layui-inline">
                    <span>（保修天数需 > =</span>
                    <span style="color: red;" th:text="${orderWarrantyVO.minDay}"></span>
                    <span>）天</span>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label"></label>
            <div class="layui-input-inline" style="width: 300px" th:if="${warrantyProductVO.startTime}">
                <span style="color: red;" class="startTime" th:text="${#dates.format(warrantyProductVO.startTime, 'yyyy年MM月dd日')}"> </span>
                <span>至</span>
                <span style="color: red;" class="endTime" th:text="${#dates.format(warrantyProductVO.endTime, 'yyyy年MM月dd日')}" ></span>
            </div>

        </div>

        <fieldset class="layui-elem-field layui-field-title" ></fieldset>
    </form>
    <div class="layui-form-item">
        <div class="layui-input-inline" style="float: right;width: 112px">
            <button class="layui-btn layui-btn-sm" lay-submit lay-filter="addition">
                <i class="layui-icon">&#xe608;</i>增加保修内容
            </button>
        </div>
    </div>

</script>

<script th:inline="javascript">
    var orderWarrantyVO = [[${orderWarrantyVO}]];
    var layuiModel = {
        oms_work_modify_warranty: "work/modify/zmn.oms.work.modify.warranty"
    };
</script>
</body>
</html>